package com.tehui.fragment;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import butterknife.ButterKnife;

/**
 * Created by jasmine on 2017/2/28.
 */

public abstract class BaseFragment extends Fragment {

    public Activity activity;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        activity = getActivity();
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle
            savedInstanceState) {
        View view = initView();
        ButterKnife.bind(this, view);
        initListener();
        return view;
    }

    public void initListener() {

    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initData();
    }

    //用于加载数据
    public void initData() {

    }

    public abstract View initView();

    public void jumpActivity(Class clazz) {
        Intent intent = new Intent(activity, clazz);
        startActivity(intent);
    }
}
